home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / faq-s.zip / NETNEW.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-31  |  10KB  |  414 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,L+,O+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit netnew;
  5.  
  6. interface
  7.  
  8. uses crt,dos,overlay,mainr2,overret1,modem,gensubs,gentypes,subs2,
  9.       protocol,subs1,configrt,statret,msg,subs3;
  10.  
  11. procedure Startnet;
  12. procedure NewNetSend;
  13. procedure DoFeatures;
  14.  
  15. implementation
  16.  
  17. type
  18.     SubSetType = set of 0..255;
  19.  
  20. var
  21.    GotPosts:boolean;
  22.  
  23.  
  24. procedure Notice(Data,data2:lstr);
  25. begin
  26.    writeln(usr,^M,data,^M,data2,^M);
  27. end;
  28.  
  29.  
  30. procedure killdir;
  31.    var r:registers; ffinfo:searchrec;
  32.        tpath:anystr; b:byte; cnt:integer; mm:text;
  33.  
  34.    begin
  35.      {Delete everything in the net directory}
  36.    end;
  37.  
  38. function checkesc:boolean;
  39. var
  40.    ch: char;
  41. begin
  42.   if keypressed then
  43.         ch:=readkey;
  44.     if ch=#27 then
  45.         checkesc:=true
  46.     else
  47.     checkesc:=false;
  48.    if not carrier then writeln(usr,'No Carrier Detected!');
  49.    if not carrier then checkesc:=true else
  50.      checkesc:=false;
  51. end;
  52.  
  53.  
  54. procedure co(color:byte);
  55. begin
  56.   textcolor(color);
  57. end;
  58.  
  59. procedure send(xx:anystr);
  60. var cnt:integer;
  61.  begin
  62.         for cnt:=1 to length(xx) do begin
  63.           sendchar (xx[cnt]);
  64.           write (usr,xx[cnt]);
  65.         end;
  66.         sendchar(#13);
  67.         write(usr,#13);
  68.  end;
  69.  
  70.  procedure zipfile(filename1,filename2:lstr);
  71.  begin
  72.    writeln(usr,'Adding ',filename2,' to ZIP file: ',filename1);
  73.    addtozip(networkdir+filename1,networkdir+filename2);
  74.  end;
  75.  
  76.  procedure unzipfile(filename1,filename2:lstr);
  77.  begin
  78.    writeln(usr,'Unzipping ',filename2,' from ',filename1);
  79.    extractzip(filename2,networkdir+filename1,networkdir);
  80.  end;
  81.  
  82. function waitfor(what:lstr):boolean;
  83.   var
  84.     s:string;
  85.     done:boolean;
  86.     cnt:longint;
  87.   begin
  88.     co(14);
  89.     done:=false;
  90.     cnt:=now+300;
  91.     s:='';
  92.     repeat
  93.       repeat until (numchars>0) or (cnt<now);
  94.       while numchars>0 do begin
  95.         delay(20);
  96.         s:=s+getchar;
  97.         write(usr,s[length(s)]);
  98.       end;
  99.         if pos(what,s)>0 then done:=true;
  100.         if checkesc then done:=true;    {bail if esc pressed}
  101.     until done or (cnt<now);
  102.     waitfor:=done;
  103.     co(4);
  104.     if done=false then writeln(usr,'Did not find what was sought.');
  105.   end;
  106.  
  107. procedure download(target:sstr);
  108.   begin
  109.     modemoutlock:=true;
  110.     co(11);
  111.     exec(getenv('COMSPEC'),' /C dsz port '+strr(usecom)+' speed '+
  112.      strlong(defbaudrate)+' rz -y '+networkdir+target);
  113.     modemoutlock:=false;
  114.     co(14);
  115.     nobreak:=true;
  116.   end;
  117.  
  118. procedure upload(source:sstr);
  119.   begin
  120.     modemoutlock:=true;
  121.     co(10);
  122.     exec(getenv('COMSPEC'),' /C dsz port '+strr(usecom)+' speed '
  123.         +strlong(defbaudrate)+' ha slow sz -n '+networkdir+source);
  124.     modemoutlock:=false;
  125.     co(14);
  126.     nobreak:=true;
  127.   end;
  128.  
  129.  
  130. Procedure PrepareStats;                 {Prepare user data for CelerityNet}
  131. var cnt:byte;
  132.     u:userrec;
  133.     {stat:UserNodeInfoRec;
  134.     statf:file of UserNodeInfoRec;}
  135.  
  136. begin
  137.   {Unused}
  138. end;
  139.  
  140. procedure processposts(host:boolean);
  141. var cnt:integer;
  142.     b:NetPostRec;
  143.     temp:file of NetPostRec;
  144. begin
  145.     if host then assign(temp,networkdir+'posts.net') else
  146.     assign(temp,networkdir+'posts.new');
  147.     reset(temp);
  148.      for cnt:=1 to filesize(temp) do begin
  149.       read(temp,b);
  150.       writeln(usr,'Moving post #',cnt,' to net sub ',b.netidnum);
  151.  
  152.       (* MoveToSub(b);    {This routine should post it on the correct sub.  Again,
  153.                         my implementation is VERY Celerity-specific}
  154.        *)
  155.     end;
  156.     close(temp);
  157.     modemoutlock:=true;
  158.      erase(temp);
  159.     modemoutlock:=false;
  160. end;
  161.  
  162.   procedure choosesubs(var SubSet: SubSetType);
  163.   begin
  164.   { This code has all been deleted as it would not be appropriate to any other
  165.     system than Celerity.  Go ahead and make your subset of subs to write to a
  166.     file (scanning through your subs).  If you're lazy, just have the sysops
  167.     make a seperate file on their disk and copy that over}
  168.  
  169.   end;
  170.  
  171.  
  172. procedure s_postman;
  173. var
  174.     SubSet: SubSetType;
  175.     x: byte;
  176.    f:file;
  177.  
  178. begin
  179.   unzipfile('incom.zip','posts.new');
  180.   writeln(usr,'Processing Posts');
  181.   processposts(false);
  182. end;
  183.  
  184. procedure s_mailman;
  185. begin
  186. end;
  187.  
  188. procedure s_statman;
  189. begin
  190. end;
  191.  
  192. procedure s_bbsman;
  193. begin
  194.   unzipfile('incom.zip','bbslist.dat');
  195.   exec(getenv('COMSPEC'),' /C copy '+networkdir+'bbslist.dat '+bbsdatadir+'bbslist.dat>nul');
  196.   exec(getenv('COMSPEC'),' /C del '+networkdir+'bbslist.dat>nul');
  197. end;
  198.  
  199. procedure s_gossip;
  200. begin
  201.   unzipfile('incom.zip','rumors.dat');
  202.   exec(getenv('COMSPEC'),' /C copy '+networkdir+'rumors.dat '+bbsdatadir+'rumors.dat>nul');
  203.   exec(getenv('COMSPEC'),' /C del '+networkdir+'rumors.dat>nul');
  204. end;
  205.  
  206. procedure s_pollster;
  207. begin
  208.   Notice('The Pollster','');
  209.   {RmWin;}
  210. end;
  211.  
  212. procedure s_netnews;
  213. begin
  214.   unzipfile('incom.zip','news.net');
  215.   Notice('Receiving Net News','');
  216.   exec(getenv('COMSPEC'),' /C copy '+networkdir+'news.net '+faqdir+'news.net>nul');
  217.   exec(getenv('COMSPEC'),' /c del '+networkdir+'news.net>nul');
  218.   {Rmwin;}
  219. end;
  220.  
  221. procedure s_stork;
  222. begin
  223.   Notice('Receiving the New Baby','');
  224.   unzipfile('incom.zip','updates.zip');
  225.   {Rmwin;}
  226. end;
  227.  
  228.  
  229. function docall:boolean;
  230.   var
  231.      resultstr,moo:lstr;
  232.      result,x:integer;
  233.      cnt:longint;
  234.   begin
  235.     co(4);
  236.     result:=0;
  237.     {if (featureb or featurec) then exit;}
  238.     setparam(usecom,defbaudrate,false);
  239.     while numchars>0 do moo:=getchar;
  240.     delay(500);
  241.     writeln(usr,'Dialing number..');
  242.     {writeln(usr,'(Fuck the aesthetics)');}
  243.     if (length(extender)>0) and (length(hostphone)>0)
  244.     then dialnumber(extender+hostphone) else if length(hostphone)>0 then dialnumber (hostphone);
  245.     writeln(usr,'Waiting for carrier...');
  246.     while numchars>0 do moo:=getchar;
  247.     cnt:=now+60;
  248.     repeat
  249.       delay(100);
  250.     until (numchars>1) or (cnt>now) or (keypressed);
  251.     cnt:=now+10;
  252.      repeat
  253.       inc(cnt);
  254.       delay(200);
  255.       ResultStr:='';
  256.       moo:='';
  257.       while numchars>0 do resultstr:=resultstr+getchar;
  258.       for x:=1 to length(resultstr) do
  259.          if ord(resultstr[x])<>13 then moo:=moo+resultstr[x];
  260.       resultstr:=moo;
  261.       val(resultstr,result,x);
  262.       if (result=11) or (result=2) then
  263.          resultstr:='';
  264.     until (length(resultstr)>0) or (cnt<now);
  265.     val(resultstr,result,x);
  266.     writeln(usr,'The Result Code is ',result);
  267.     delay(1000);
  268.     case result of
  269.       0,1,10,13,17,23,27,28,29,19,14:begin
  270.         docall:=true;
  271.         writelog(21,2,'');
  272.         end
  273.       else begin
  274.         docall:=false;
  275.         writeln(21,3,'');
  276.         end;
  277.     end;
  278.    end;
  279.  
  280. procedure preparepack;
  281. var i:byte;
  282.     f:text;
  283.     subset:subsettype;
  284.  
  285. begin
  286.   ChooseSubs(subset);
  287.   assign(f,networkdir+'SENDSUBS');
  288.   rewrite(f);
  289.   for i:=1 to 255 do if i in subset then writeln(f,i);
  290.   i:=0;
  291.   write(f,i);
  292.   textclose(f);
  293.   exec(getenv('COMSPEC'),' /c ren '+networkdir+'posts.out posts.net >nul');
  294.   zipfile('outgo.zip','posts.net');
  295.   zipfile('outgo.zip','bbslist.new');
  296.   zipfile('outgo.zip','rumors.new');
  297.   exec(getenv('COMSPEC'),' /c del '+networkdir+'*.new >nul');
  298.   zipfile('outgo.zip','sendsubs');
  299.   exec(getenv('COMSPEC'),' /c del '+networkdir+'sendsubs >nul');
  300. end;
  301.  
  302.  
  303. procedure dofeatures;
  304. var cnt:longint;
  305. begin
  306.   writeln(usr,'Extracting net data...');
  307.   if featurea then s_postman;
  308.   if featureb then s_mailman;
  309.   if featurec then s_statman;
  310.   if featured then s_bbsman;              {How about making feature an array?}
  311.   if featuree then s_gossip;                         {And making this a case}
  312.   if featuref then s_netnews;
  313.   if featureg then s_pollster;
  314.   if featureh then s_stork;
  315.   if featurej then ;
  316. end;
  317.  
  318. procedure StartNet;
  319. begin
  320. writestr ('Node:*');
  321. writestr (^M'Pass:*');
  322. if not match(input,netpas) then begin
  323. hangupmodem; if local then halt (2); end;
  324. delay(50);
  325. writestr ('Features:*');
  326. download ('OUTGO.ZIP');
  327.   while numchars>0 do write(usr,getchar);
  328.   writeln('*Sending Packet*');
  329.   preparepack;
  330.   upload('INCOM.ZIP');
  331.   hangupmodem; if local then halt (2);
  332.   sendmodemstr ('~ATH1|',true);
  333.   writeln('Processing Data');
  334.   DoFeatures;
  335.   killdir;
  336.   delay(1000);
  337.   sendmodemstr ('~ATH|',true);
  338. end;
  339.  
  340. procedure NewNetsend;
  341. var
  342.    netfile:text;
  343.    cnt:integer;
  344.    features:string[10];
  345.    subset:subsettype;
  346.  
  347.  
  348. begin
  349.   if not docall then begin
  350.     co(4);
  351.     writeln('Failed.');
  352.     hangupmodem;
  353.     delay(1000);
  354.     exit;
  355.   end;
  356.  
  357.   GotPosts:=false;
  358.   co(14);
  359.   clrscr;
  360.   online:=true;local:=false;modemoutlock:=false;modeminlock:=false;
  361.  
  362.   cnt:=0;
  363.   while (numchars<10) and (cnt<1000) do begin
  364.     delay(10);
  365.     inc(cnt);
  366.   end;
  367.  
  368.   if checkesc then exit;
  369.   while(numchars>0) do begin
  370.     write(usr,getchar);
  371.     delay(10);
  372.   end;
  373.   send('New Net Buddy!');
  374.   if not waitfor('Node:') then exit;
  375.   send(strr(netnum));
  376.   if not waitfor('Pass:') then exit;
  377.   send(netpas);
  378.   delay(50);
  379.   if checkesc then exit;    {bail if esc pressed}
  380.   if not waitfor('Features:') then exit;
  381.   features:='';
  382.   if featurea then features:=features+'A';
  383.   if featured then features:=features+'D';
  384.   if featured then features:=features+'E';
  385.   if featured then features:=features+'F';
  386.   send(features);
  387.   PreparePack;
  388.  
  389.   Upload('OUTGO.ZIP');
  390.   if not carrier then begin
  391.     writeln(usr,^M^M'Carrier lost.  Aborting netcall.');
  392.     exit;
  393.   end else
  394.   killdir;
  395.   while numchars>0 do write(usr,getchar);
  396.   delay(10000);
  397.   if not waitfor('*Sending Packet*') then exit;
  398.   download('INCOM.ZIP');
  399.   hangupmodem;
  400.   sendmodemstr ('~ATH1|',true);
  401.   writeln('Processing Data');
  402.   DoFeatures;
  403.   killdir;
  404.   netmade:=true;
  405.   writestatus;
  406.   writelog(21,4,'');
  407.   delay(1000);
  408.   sendmodemstr ('~ATH|',true);
  409. end;
  410.  
  411. begin
  412. end.
  413.  
  414.